﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Prism.ViewModel;
using System.Windows.Input;

using System.Windows;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Events;
using Infrastructure.Events;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;

using SystemModule.Commands;
using Infrastructure.Helpers;

namespace SystemModule.ViewModels
{
    /// <summary>
    /// ViewModel for CatalogManagerMenuView.
    /// </summary>
    public class SystemManagerMenuViewModel : NotificationObject
    {

        #region Fields
        IEventAggregator eventAggregator;
        IUnityContainer container;
        IRegionManager regionManager;

        // Property variables
        bool isVisible;

        #endregion

        #region Constructor
        /// <summary>
        /// Default constructor.
        /// </summary>
        public SystemManagerMenuViewModel(IEventAggregator eventAggregator, IRegionManager regionManager, IUnityContainer container)
        {
            this.container = container;
            this.eventAggregator = eventAggregator;
            this.regionManager = regionManager;
            this.Initialize();

            this.ShowNhomNguoiDungViewCommand = container.Resolve<ShowNhomNguoiDungViewCommand>(
                new ParameterOverrides 
                {
                    {"viewModel", this}
                }.OnType<ShowNhomNguoiDungViewCommand>()
            );
            this.ShowNguoiDungViewCommand = container.Resolve<ShowNguoiDungViewCommand>(
                new ParameterOverrides 
                {
                    {"viewModel", this}
                }.OnType<ShowNguoiDungViewCommand>()
            );
            this.ShowQuyenViewCommand = container.Resolve<ShowQuyenViewCommand>(
                new ParameterOverrides 
                {
                    {"viewModel", this}
                }.OnType<ShowQuyenViewCommand>()
            );
        }
        #endregion

        #region Command Properties
        public ICommand ShowNhomNguoiDungViewCommand { get; set; }
        public ICommand ShowNguoiDungViewCommand { get; set; }
        public ICommand ShowQuyenViewCommand { get; set; }
        #endregion

        #region Administrative Properties
        public bool IsVisible
        {
            get { return isVisible; }
            set
            {
                isVisible = value;
                RaisePropertyChanged(() => this.IsVisible);
            }
        }

        public IRegionManager RegionManager
        {
            get { return regionManager; }
        }

        public IEventAggregator EventAggregator
        {
            get { return eventAggregator; }
        }

        public IUnityContainer Container
        {
            get { return container; }
        }
        #endregion

        #region Event Handlers

        #endregion

        #region Private Methods
        /// <summary>
        /// Initializes the view model.
        /// </summary>
        private void Initialize()
        {
            // Initialize the UI properties
            IsVisible = PermissionChecker.HasQuyenQuanLyHeThong();
            
        }
        #endregion
    }
}
